/**
 * 健康管理相关API
 */
import request from '../request'
import type {
  ApiResponse,
  PageResponse,
  HealthArchive,
  ArchiveListParams,
  SaveArchiveParams,
  AuditArchiveParams,
  BatchAuditParams,
  HealthReport,
  ReportListParams,
  SaveReportParams,
  IndicatorListParams,
  IndicatorData
} from '../types'

// ==================== 健康档案 ====================

/**
 * 获取健康档案列表
 */
export function getArchiveList(params: ArchiveListParams): Promise<PageResponse<HealthArchive>> {
  return request.get('/admin/health/archive/list', params)
}

/**
 * 获取健康档案详情
 */
export function getArchiveDetail(id: string): Promise<ApiResponse<HealthArchive>> {
  return request.get(`/admin/health/archive/detail/${id}`)
}

/**
 * 新增健康档案
 */
export function createArchive(data: SaveArchiveParams): Promise<ApiResponse<null>> {
  return request.post('/admin/health/archive', data)
}

/**
 * 编辑健康档案
 */
export function updateArchive(id: string, data: SaveArchiveParams): Promise<ApiResponse<null>> {
  return request.put(`/admin/health/archive/${id}`, data)
}

/**
 * 删除健康档案
 */
export function deleteArchive(id: string): Promise<ApiResponse<null>> {
  return request.delete(`/admin/health/archive/${id}`)
}

/**
 * 审核健康档案
 */
export function auditArchive(data: AuditArchiveParams): Promise<ApiResponse<null>> {
  return request.put('/admin/health/archive/audit', data)
}

/**
 * 批量审核健康档案
 */
export function batchAuditArchive(data: BatchAuditParams): Promise<ApiResponse<null>> {
  return request.put('/admin/health/archive/audit/batch', data)
}

// ==================== 体检报告 ====================

/**
 * 获取体检报告列表
 */
export function getReportList(params: ReportListParams): Promise<PageResponse<HealthReport>> {
  return request.get('/admin/health/report/list', params)
}

/**
 * 获取体检报告详情
 */
export function getReportDetail(id: string): Promise<ApiResponse<HealthReport>> {
  return request.get(`/admin/health/report/detail/${id}`)
}

/**
 * 新增体检报告
 */
export function createReport(data: SaveReportParams): Promise<ApiResponse<null>> {
  return request.post('/admin/health/report', data)
}

/**
 * 编辑体检报告
 */
export function updateReport(id: string, data: SaveReportParams): Promise<ApiResponse<null>> {
  return request.put(`/admin/health/report/${id}`, data)
}

/**
 * 删除体检报告
 */
export function deleteReport(id: string): Promise<ApiResponse<null>> {
  return request.delete(`/admin/health/report/${id}`)
}

// ==================== 健康指标 ====================

/**
 * 获取健康指标列表（按用户查询）
 */
export function getIndicatorList(params: IndicatorListParams): Promise<ApiResponse<IndicatorData>> {
  return request.get('/admin/health/indicator/list', params)
}
